<script setup>
import NavigationBar from '../components/index/navigation/NavigationBar.vue'
import BottomBar from '../components/index/bottom/bottombar.vue'
import { ref, onMounted, watch } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import axios from 'axios'
import jwt_decode from "jwt-decode";

const router = useRouter()

let token = jwt_decode(localStorage.getItem("token"))
if (token == null) {
  token = jwt_decode(localStorage.getItem("longToken"))
}
function findPayPassword() {
  axios.get('http://192.168.110.221:8080/user/queryPayPasswordController', {
    params: {
      token: localStorage.getItem("token"),
      longToken: localStorage.getItem("longToken"),
      userNumber: token.userNumber
    }
  })
    .then((resp) => {
      console.log(resp.data.code);
      if (resp.data.code == 200) {

      } else {
        router.push('/pay-password-setting')
      }
    })
}
onMounted(() => {
  if (token == null) {
    router.push('/login')
  } else {
    findPayPassword()
  }

})

//底部导航栏传回来的值
const comparebottombank = ref('我的钱包')
//将底边栏和导航栏的数据做个判断 相等则切换对应的
function bankcard(Bankcard) {
  comparebottombank.value = Bankcard
}

const middle = ref('')

function change(num1) {
  middle.value = num1
}

//将底部导航栏传回来的值传到导航栏中做判断

</script>

<template>
  <div class="common-layout">
    <el-container>
      <el-header>
        <NavigationBar :type1="comparebottombank" :num1="middle" />
      </el-header>
      <el-main>
        <router-view @change="change($event)" />
      </el-main>
      <el-footer>
        <BottomBar @changeBankcard="bankcard" />
        <div class="add">

        </div>
      </el-footer>
    </el-container>
  </div>
</template>

<style scoped>
.add {
  width: 100%;
  height: 50px;
  z-index: -100px;
}
</style>